define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'hf/qdorder2/index' + location.search,
                    add_url: 'hf/qdorder2/add',
                    edit_url: 'hf/qdorder2/edit',
                    del_url: 'hf/qdorder2/del',
                    multi_url: 'hf/qdorder2/multi',
                    import_url: 'hf/qdorder2/import',
                    table: 'hf_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false, // 浏览模式切换
                showColumns: true, // 允许选择显示字段
                showExport: true, // 导出选项
                exportDataType: "basic", //导出当前页
                exportTypes: ['excel'],
                searchFormVisible: false, // 通用搜索 默认是否显示
                search: false, // 是否关闭搜索
                trimOnSearch: true, // 自动删除搜索空格
                pageList: [10, 20, 30, 50],
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [{
                            checkbox: true
                        },
                        {
                            field: 'admin_id',
                            title: __('渠道ID')
                        },
                        {
                            field: 'orderno',
                            title: __('Orderno'),
                            operate: 'LIKE'
                        },

                        {
                            field: 'image',
                            title: __('Image'),
                            operate: false,
                            events: Table.api.events.image,
                            formatter: Table.api.formatter.image
                        },
                        {
                            field: 'title',
                            title: __('Title'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'from',
                            title: __('From'),
                            searchList: {
                                "1": __('From 1'),
                                "2": __('From 2'),
                                "3": __('API'),
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'account',
                            title: __('Account'),
                            operate: '='
                        },
                        {
                            field: 'statuss',
                            title: __('Statuss'),
                            searchList: {
                                "1": __('Statuss 1'),
                                "2": __('Statuss 2'),
                                "3": __('Statuss 3'),
                                "4": __('Statuss 4'),
                                "5": __('Statuss 5')
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'remark',
                            title: __('Remark'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'createtime',
                            title: __('Createtime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        }, {
                            field: 'updatetime',
                            align: 'left',
                            title: __('时间'),
                            operate: false,
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: function (val, r) {
                                return "更新时间：" + r.t1 + "<br>" + '<span style="color: red;">耗时：' + r.date + '</span>';
                                //  return r.t1;
                            }
                        },

                        {
                            field: 'mz',
                            title: __('Mz')
                        },

                        {
                            field: 'yys',
                            title: __('Yys'),
                            searchList: {
                                "0": __('Yys 0'),
                                "1": __('Yys 1'),
                                "2": __('Yys 2'),
                                "3": __('Yys 3'),
                                "4": __('Yys 4'),
                                "5": __('Yys 5'),
                                "6": __('Yys 6'),
                                "7": __('Yys 7')
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'cztype',
                            title: __('Cztype'),
                            searchList: {
                                "1": __('Cztype 1'),
                                "2": __('Cztype 2')
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'price',
                            title: __('Price'),
                            operate: 'BETWEEN'
                        },



                        {
                            field: 'user_id',
                            title: __('User_id')
                        }, {
                            field: 'province',
                            title: __('Province'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        }, {
                            field: 'city',
                            title: __('City'),
                            operate: 'LIKE'
                        },


                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});